<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
request.setCharacterEncoding("UTF-8");
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<base href="<%=basePath%>">
<title>分公司机构配置</title>
<script language="javascript" type="text/javascript">
	//加载deptTree（所属机构）
	function loadDeptTree(){
	$.openLoading();
	
	$.ajax({
		url : "<%=path%>/channelManage/queryBranchDept?"+new Date().getTime(),
		type : 'POST',
		async : true,
		dataType:'json',
		success:function(data){
			
			var setting = {
					check: {
						enable: true,
						chkStyle: "radio",
						radioType: "all"
					},
					data: {
						simpleData: {
							enable: true
						}
					}
				};

				$.fn.zTree.init($("#deptTree"), setting, data);
				
				$("#deptTreeDiv").OpenDiv2();
		},
		complete:function (){
			$.closeLoading();
		}
	});
	}
	
	//隐藏deptTree层
	function closeDeptTreeDiv(){
		$("#deptTreeDiv").CloseDiv2();
	}
	
	//点击"确定"（选择所属dept）
	function chooseDept(){
		var deptTree = $.fn.zTree.getZTreeObj("deptTree");
		if(deptTree.getCheckedNodes(true).length==0){
			$.message("error", "请选择一个公司后确定");
			return;
		}
		var depts = deptTree.getCheckedNodes(true);
		$("#deptCname_div").val(depts[0].name);
		$("#deptCode_div").val(depts[0].id);
		
		$("#deptTreeDiv").CloseDiv2();
	}
	
</script>

 </head>
  <body>
  	<%--deptTree(选择所属机构层) --%>
    <div id="deptTreeDiv" style="display: none;width:500px" align="center">
    	<div class="table_title_div">
				<table class="table_title" style='width:100%; height: 20px;'>
					<tr>
						<td width="10%"></td>
						<td width="80%" id="interfaceName"></td>
						<td width="10%" align="right"><img src="<%=path %>/images/closedown.gif" alt="关闭"  onclick="closeDeptTreeDiv()"/></td>
					</tr>
				</table>
		</div>
		
		<div style="height: 300px;overflow-y:auto">
			<ul id="deptTree" class="ztree"></ul>
		</div>
		
		<div style="text-align: center;padding: 5px">
			<input type="button" id="choseDeptBtn" value="确定" onclick="chooseDept()" class="input_button_1"/>&nbsp;&nbsp;&nbsp;
			<input type="button" value="取消" onclick="closeDeptTreeDiv()" class="input_button_1"/>
		</div>
	</div>
  </body>
</html>
